package com.hctforgreen.greenservice;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hctforgreen.greenservice.ui.adapter.QueryMessageListAdapter;
import com.hctforgreen.greenservice.ui.handler.QueryMessageListHandler;
import com.hctforgreen.greenservice.ui.widget.PullToRefreshListView;
import com.hctforgreen.greenservice.utils.ThemeStoreUtil;

/**
 * 通知搜索结果列表页
 * 
 * @author ld
 * 
 */
public class MessageListActivity extends ParentActivity implements
		OnClickListener {
	private Activity context;
	private String dateFrom;
	private String type = "1";// 1管理通知 2技术通知 3软件通知
	private String seriesId;// 技术类型
	private String keywords;// 搜索关键字

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		context = this;
		dateFrom = getIntent().getStringExtra("dateFrom");
		type = getIntent().getStringExtra("type");
		seriesId = getIntent().getStringExtra("seriesId");
		keywords = getIntent().getStringExtra("keywords");
		setContentView(R.layout.activity_msg_list);
		initSkinLayout();
		initTitleButtonBar();
		initWindow();
	}

	private void initTitleButtonBar() {
		final TextView titleTv = (TextView) findViewById(R.id.tv_title);
		titleTv.setText(getString(R.string.message_title_hint));

		final ImageButton backBtn = (ImageButton) findViewById(R.id.btn_back);
		backBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	private void initWindow() {
		initRecentMessageList();
	}

	private void initRecentMessageList() {
		View convertView = findViewById(R.id.lyt_parent);
		PullToRefreshListView listView = (PullToRefreshListView) convertView
				.findViewById(R.id.lst_default_list);
		QueryMessageListHandler handler = new QueryMessageListHandler(this,
				convertView, dateFrom, type, seriesId, keywords);
		new QueryMessageListAdapter(listView, this, convertView,
				R.layout.layout_loading, R.layout.layout_reloading, handler);
		// getMsgList(dateFrom);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.search_btn:
			break;

		default:
			break;
		}
	};
}
